#include <bits/stdc++.h>
using namespace std;

int d[1000005];
int b[1005];
int a[1005];
int p[100005];

int main()
{
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	ios::sync_with_stdio(false);
	int t, n, m, l, v;
	cin >> t;
	for(int i = 1; i <= t; i++)
	{
		cin >> n >> m >> l >> v;
		for(int j = 1; j <= n; j++)
		{
			cin >> d[j] >> b[j] >> a[j];
		}
		for(int k = 1; k <= m; k++)
		{
			cin >> p[k];
		}
	}
	for(int i = 1; i <= t; i++)
	{
		int jsq = 0, ans = m, s = 0, r = 0;
		for(int j = 1; j <= n; j++)
		{
			if(a[j] == 0)
			{
				if(b[j] > v) 
				{
					jsq++;
					ans = ans - 2;
				}
			}
			else if(a[j] > 0)
			{
				for(int l = 1; l <= m; l++)
				{
					if(p[l] == d[j]) jsq++;
					else
					{
						s = p[m] - d[j];
						r = sqrt(b[j] * b[j] + 2 * a[j] * s);
						if(r > v)
						{
							jsq++;
							ans = ans - 2;
						}
						break;
					}
				}
				
			}
				else if(a[j] < 0)
				{
					jsq = 0;
					ans = ans - 2;
				}
		}
		cout << jsq << " " << ans;
	}
	fclose(stdin);
	fclose(stdout);
	return 0;
}
